/*
 * condition.c
 *
 *  Created on: 2019年5月7日
 *      Author: Administrator
 */

#include <stdio.h>
#include <string.h>
#include "../include/condition.h"

void condition_if() {

	// if
	int counter = 0;
	float input_data;
	while (counter != 5) {
		scanf("%f\n", &input_data);
		if (input_data < 20 && input_data > 0) {
			counter++;
			printf("counter: %d \n", counter);
		}
	}
}

void condition_switch(char grades[]) {

	int counter = 0;
	int length = strlen(grades);

	for (int i = 0; i < length; i++) {
		switch (grades[i]) {
		case 'A':
			printf("%c:很棒！\n", grades[i]);
			counter++;
			break;
		case 'B':
			printf("%c:做得好！\n", grades[i]);
			counter++;
			break;
		case 'C':
			printf("%c:您通过了！\n", grades[i]);
			counter++;
			break;
		case 'D':
			printf("%c:在接在励！\n", grades[i]);
			break;
		default:
			printf("%c:成绩无效！\n", grades[i]);
		}
	}

	printf("成绩及格共有%d个 \n", counter);
}

